package problem;

import java.util.Iterator;

import utils.Dijkstra;
import env.City;
import env.DistList;
import env.World;

public class Heuristic {

	public static int getHeuristic(World world, City goal) {
		int res=0;
		Iterator<City> it = world.getCities().iterator();
		while (it.hasNext()) {
			City city = (City) it.next();
			int chemsInCity = city.getChems();
			if (chemsInCity>0) {
				DistList distList = Dijkstra.runDijkstra(world, city, false);
				int distance = distList.getDistance(goal);
				if(distance<Integer.MAX_VALUE)
					res=res + distance*chemsInCity;
			}
		}
		return res*2;
	}
	
}
